module.exports = function modelGenerator(name) {
  const formatName = name
    .trim()
    .toLowerCase()
    .replace(name[0], name[0].toUpperCase());
  return `import { Reducer, Effect, Subscription } from 'umi';

export interface ${formatName}ModelState {
    demo: any;
}

export interface ${formatName}ModelType {
  namespace: '${name}';
  state: ${formatName}ModelState;
  effects: {
    ${name}Demo: Effect;
  };
  reducers: {
    save: Reducer<${formatName}ModelState>;
  };
  subscription: {
    setup: Subscription;
  };
}

const ${formatName}Model: ${formatName}ModelType = {
  namespace: '${name}',
  state: {
    demo: 'demo'
  },
  effects: {
    *${name}Demo({ payload }, { call, put }) {
    },
  },
  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
  subscription: {
    setup() {},
  },
};

export default ${formatName}Model;
`;
};
